package cn.sjx.basic.service.impl;

import cn.sjx.auth.domain.Permission1;
import cn.sjx.basic.mapper.BasicMapper;
import cn.sjx.basic.service.BasicService;
import cn.sjx.basic.utils.BasicQuery;
import cn.sjx.basic.utils.PageList;
import cn.sjx.org.domain.Department;
import cn.sjx.org.query.DepartmentQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;


public  class BasicServiceImpl<T> implements BasicService<T> {
    @Autowired
    BasicMapper<T> basicMapper;

    @Override
    public List<T> getAll() {
        return basicMapper.getAll();
       
    }

    @Override
    public T getById(Serializable id) {
       return basicMapper.getById(id);

    }

    @Override
    public void insert(T t) {
        basicMapper.insert(t);
    }

    @Override
    public void update(T t) {
        basicMapper.update(t);
    }

    @Override
    public void deleteById(Serializable id) {
        basicMapper.deleteById(id);
    }

    @Override
    public PageList<T> pageList(BasicQuery basicQuery) {
        Long total = basicMapper.loadTotal(basicQuery);
        if (total == 0) {
            return new PageList<>();
        }else {
            List<T> list = basicMapper.loadData(basicQuery);

            return new PageList<>(total,list);
        }
    }



    @Override
    public void batchRemove(List<Long> ids) {
        basicMapper.batchRemove(ids);
    }

    @Override
    public List<T> tree() {
        return basicMapper.tree();
    }
}
